<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<script src="webpage/material/orderInfo/orderProductList.js"></script>
<script src="webpage/material/common/selectProduct.js"></script>
<script type="text/javascript">
	$('#addOrderProductBtn').linkbutton({   
	    iconCls: 'icon-add'  
	});  
	$('#delOrderProductBtn').linkbutton({   
	    iconCls: 'icon-remove'  
	}); 
	 
	$('#delOrderProductBtn').bind('click', function(){   
      	$("#add_orderProduct_table").find("input:checked").parent().parent().remove();   
        resetTrNum('add_orderProduct_table'); 
        return false;
    }); 
    $(document).ready(function(){
    	$(".datagrid-toolbar").parent().css("width","auto");
    	if(location.href.indexOf("load=detail")!=-1){
			$(":input").attr("disabled","true");
			$(".datagrid-toolbar").hide();
		}
		//将表格的表头固定
	    $("#orderProduct_table").createhftable({
	    	height:'300px',
			width:'auto',
			fixFooter:false
			});
    });
</script>
<style>
th{
bgcolor:#E6E6E6;
}
th,td{
width:75px;
align:center;
}
</style>
<div style="padding: 3px; height: 25px;width:auto;" class="datagrid-toolbar">
	<a id="addOrderProductBtn" href="#" onclick="addBtnClick();">选择产品</a> <a id="delOrderProductBtn" href="#">删除</a> 
</div>
<table border="0" cellpadding="2" cellspacing="0" id="orderProduct_table">
	<tr>
	<th style="display: none">
			id
		</th>
		<th> 选择</th>
				  
				  <th >
						产品名称
				  </th>
				  
	
		<th>
			产品分类
		</th>
		<th>
			生产厂家
		</th>
		<th>
			型号
		</th>
		<th>
			规格
		</th>
					  <th>
			个数
		</th>
					  <th>
			单价
		</th>
					  <th>
			总价
		</th>
	</tr>
	<tbody id="add_orderProduct_table">	
		<c:forEach items="${orderProductList}" var="poVal" varStatus="stuts">
			<tr>
			<td  style="display:none">
				<input type="hidden" name="orderProductList[${stuts.index }].productId.id" value="${poVal.productId.id}"/>	
				</td>
				
				<td align="center"><input style="width:20px;"  type="checkbox" name="ck" /></td>
					
				
				
				<td >
					${poVal.productId.typeThree.name}
				</td>
				<td >
					${poVal.productId.manufacturer}
				</td>
				<td >
					${poVal.productId.model}
				</td>
				<td >
					${poVal.productId.specification}
				</td>
				<td >
<<<<<<< HEAD
				    <input type="text" datatype="*" style="width: 75px;" name="orderProductList[${stuts.index }].amount" value="${poVal.amount}" />	
				</td>
				<td >
				    <input type="text" datatype="*" style="width: 75px;" name="orderProductList[${stuts.index }].price" value="${poVal.price}" />	
				</td>
				<td >
				    <input type="text" datatype="*" style="width: 75px;" name="orderProductList[${stuts.index }].totalPrice" value="${poVal.totalPrice}" />	
=======
				    <input type="text" datatype="d" style="width: 75px;" name="orderProductList[${stuts.index }].amount" errormsg="非法输入" class="easyui-textbox" onblur="compute(${stuts.index })" value="${poVal.amount}" />	
				</td>
				<td >
				    <input type="text" datatype="d" style="width: 75px;" name="orderProductList[${stuts.index }].price"  errormsg="非法输入"  class="easyui-textbox" onblur="compute(${stuts.index })" value="${poVal.price}" />	
				</td>
				<td >
				    <input type="text" datatype="d" style="width: 75px;" name="orderProductList[${stuts.index }].totalPrice" errormsg="非法输入" class="easyui-textbox" onblur="compute([${stuts.index }])" value="${poVal.totalPrice}" />	
>>>>>>> a9c7731b4788b28c37d962faa7843e2cac438e61
				</td>
   			</tr>
		</c:forEach>
	</tbody>
</table>
<<<<<<< HEAD
=======

<script type="text/javascript">
     function compute(id){
       //计算总价
       var totalPrice =Number($("input[name='orderProductList["+id+"].amount']").val()) *Number($("input[name='orderProductList["+id+"].price']").val())  ;
       $("input[name='orderProductList["+id+"].totalPrice']").val(totalPrice);
        
        var allPrice=0;
        $tbody.find('>tr').each(function(i) {
			 allPrice=Number(allPrice)+Number( $("input[name='orderProductList["+i+"].totalPrice']").val());
		});
		
		$("input[name='totalPrice").val(allPrice);
		
        
     }
</script>
>>>>>>> a9c7731b4788b28c37d962faa7843e2cac438e61
